<!-- 订单 -->
<template>
  <div class="order-main">
    <Navbar :title="title" />
    <van-contact-card
      :type="cardType"
      :name="addressDetail.name"
      :tel="addressDetail.mobile"
      @click="goAddressList"
    />

    <div class="goodsInfo">
      <div class="goodsItem">
        <div class="name">商品合计</div>
        <div class="val">¥{{ allPrise }}</div>
      </div>
      <div class="goodsItem">
        <div class="name">运费</div>
        <div class="val">免运费</div>
      </div>
      <div class="goodsItem">
        <div class="name">优惠券</div>
        <div class="val">暂无</div>
      </div>
    </div>

    <div class="goodsShow">
      <div class="goodsShowItem" v-for="item in goodsList" :key="item.id">
        <div class="left">
          <img class="img" :src="item.list_pic_url" alt="" />
          <div class="goodsdes">
            <div class="name">{{ item.goods_name }}</div>
            <div class="price">¥ {{ item.retail_price }}</div>
          </div>
        </div>
        <div class="num">x{{ item.number }}</div>
      </div>
    </div>

    <div class="pay">
       <div class="pricetotal">实付:¥ {{allPrise}}</div>
       <div class="btn" @click="doPay">支付</div>
    </div>
  </div>
</template>

<script>
import Navbar from "@/components/Navbar";
import orderApi from "@/api/order/index";
import Vue from "vue";
import { ContactCard, ContactList, ContactEdit, Toast } from "vant";

Vue.use(ContactCard).use(ContactList).use(ContactEdit);
export default {
  name: "order",
  components: {
    Navbar,
  },
  data() {
    return {
      title: "订单确认",
      addressDetail: {},
      allPrise: "",
      goodsList: [],
    };
  },
  created() {
    this.getdetailAction();
  },
  computed: {
    cardType() {
      return this.chosenContactId !== null ? "edit" : "add";
    },
  },
  methods: {
    getdetailAction() {
      orderApi
        .orderDetail({
          openId: "15845697415",
          addressId: "",
        })
        .then((res) => {
          this.addressDetail = res.address;
          this.allPrise = res.allPrise / 100;
          this.goodsList = res.goodsList;
        });
    },
    goAddressList() {
      this.$router.push({ name: "address" });
    },
    doPay(){
        Toast({
            message:'支付功能暂未开通'
        })
    }
  },
};
</script>
<style lang='scss' scoped>
.order-main {
   height: 5000px; 
  .goodsInfo {
    margin-top: 12px;
    background-color: #fff;
    .goodsItem {
      margin: 0 15px;
      height: 46px;
      line-height: 46px;
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #f3f3f3;
    }
  }
  .goodsShow {
    margin-top: 12px;
    background-color: #fff;
    .goodsShowItem {
      height: 115px;
      margin: 0 15px;
      display: flex;
      justify-content: space-between;
      border-bottom:1px solid  #f3f3f3;
      .left {
         height: 100%;
         display: flex;
         justify-content: flex-start;
        .img {
          width: 63px;
          height: 63px;
          background-color: #f4f4f4;
          margin-top: 26px;
        }
        .goodsdes {
          margin-left: 10px;
          .name {
            margin: 35px 0 8px 0;
          }
        }
      }
      .num {
        margin-top: 58px;
      }
      
    }
  }
  .pay{ 
     position: relative;
     padding-left: 10px;  
     background-color: #fff;
     height: 50px;
     width: 100%;
     line-height: 50px;
     position: fixed;
     bottom: 0;
     left: 0;
     .btn{
         position: absolute;
         right: 0;
         top: 0;
         width: 100px;
         height: 100%;
         background-color: #B4282D;
         text-align: center;
         color: #fff;
     }
  }
}
</style>